<?php
/*=============================================================================
|| ##################################################################
||	phpFoX Konsort
|| ##################################################################
||
||	Copyright		: (C) 2005-2007 PHPFOX Limited a Reality Fox Creation
||	Contact			: info@phpfox.com
||
||	- phpFoX and all of its source code and files are protected by Copyright Laws.
||
||	- The license for phpFoX permits you to install this software on a single domain (.com, .org, .net, etc.).
||
||	- You may also not remove this copyright screen which shows the copyright information and credits for phpFoX (RealityFOX Creations).
||
||	- phpFoX Konsort is NOT a FREE software - http://www.phpfox.com/license/
||
|| ##################################################################
=============================================================================*/

/* $File: ./include/modules/Listing/classes/PhpFox_ComponentViewMy.class.php, $Author:  $ */



/** Display list classifieds
 *
 * Parameters:
 *  1. oUser (mandatory) - user account object
 *
 * @package module.listing
 * @version $Id:
 *   PHPFox Team ()
 */
class PhpFox_Mod_Listing_ComponentViewMy extends BaseComponent
{
	function process()
	{
		App::membersOnly();

	    //check permissions
        $oSecurityService = App::getModuleService('Account', 'Security');

        $oSecurityService->checkPerm('listing', array('read_only', 'full'));
		/* @var $oSecurityService PhpFox_Mod_Account_ServiceSecurity */
		$oListingService = $this->_oModule->getService('Listing');
		$oUser = $oSecurityService->getCurrentUser();

        $oReq = &App::getRequest();
        $iPageSize = App::getParam('public.pagesize');
        $iPage = $oReq->getInt('page', 1);
        $aCond = array();
        $sOrder = 'time DESC';
        $aCond['user'] = '="'.$oSecurityService->getCurrentUserLogin().'"';

        list($aListing, $iCnt) = $oListingService->getListingByCategory($aCond, $iPage, $iPageSize, $sOrder);

        foreach ($aListing as $i=>$aList)
        {
            $aListing[$i]['bloc'] = true;
            if(!is_readable(App::getParam('flag.pic.path').$aListing[$i]['location'].'.gif'))
            {
                $aListing[$i]['srcf'] = App::getParam('flag.pic.url').'Unknown.gif';
                $aListing[$i]['bloc'] = false;
            }
            else
                $aListing[$i]['srcf'] = App::getParam('flag.pic.url').$aListing[$i]['location'].'.gif';
        }
        $oPager = App::newObject('Pager', $iCnt, $iPage, $iPageSize);

        $oTpl = $this->_oModule->getTemplate();



        $oTpl->assignSrc(array(
                               'aErrors'      => $this->getErrors(),
                               'aListing'     => !empty($aListing) ? $aListing : '',
                               'aPaging'      => $oPager->getInfo(App::getUrl())
                         ));

        $srcHtml = $oTpl->fetch('ViewMy.html');
		return $srcHtml;
	}
}
?>